package com.hgy.plugin.security;

import java.util.Set;

import javax.servlet.FilterRegistration;
import javax.servlet.ServletContainerInitializer;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;

import org.apache.shiro.web.env.EnvironmentLoaderListener;

/**
 * Smart Security 插件
 * 
 * @author alone
 *
 */
public class SmartSecurityPlugin implements ServletContainerInitializer{

	
	@Override
	public void onStartup(Set<Class<?>> handlerTypes, ServletContext servletContext)
			throws ServletException {
		
		// 设置初始参数
		servletContext.setInitParameter("shiroConfigLocations", "classpath:smart-security.ini");
		// 注册 Listener
		servletContext.addListener(EnvironmentLoaderListener.class);
		// 注册 Filter
		FilterRegistration.Dynamic smartSecurityFilter = servletContext.addFilter("SmartSecurityFilter", SmartSecurityFilter.class);
		smartSecurityFilter.addMappingForUrlPatterns(null, false, "/*");
	}

}
